<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;  
use App\Http\Controllers\Controller;  
use Gregwar\Captcha\CaptchaBuilder;  
use Session;

class CodeController extends Controller
{
    public function captcha()
    {
    	//生成验证码图片的builder对象，配置属性
    	$builder = new CaptchaBuilder;
    	//设置图片宽高
    	$builder->build($width = 100,$height = 40,$font = null);
    	//获取验证码内容
    	$phrase = $builder->getPhrase();
    	//把内容放入session
    	session(['code'=>$phrase]);
    	//生成图片
    	header("Cache-Control: no-cache, must-revalidate");  
        header('Content-Type: image/jpeg');  
        $builder->output();  
    }
}
